package com.jinyang.jetpackdemo.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.jinyang.jetpackdemo.bean.ArticleItem
import com.jinyang.jetpackdemo.util.http.Result
import com.jinyang.jetpackdemo.util.http.RetrofitUtils
import com.jinyang.jetpackdemo.util.http.RetrofitUtils.get
import com.jinyang.jetpackdemo.util.http.model.Parameter
import kotlinx.coroutines.launch

/**
 * @Author:         LiuJinYang
 * @CreateDate:     2021/8/12
 * @Description:
 */
class ArticleListViewModel : ViewModel() {
    val articleList = MutableLiveData<List<ArticleItem>>()
    val isLoading = MutableLiveData<Boolean>()
    fun getList() {
        get(
            "sss",
            Parameter(),
            ArticleItem::class.java,
            resultList = true,
            onSuccess = { msg, data ->

            },
            onError = { errorCode, errorMsg ->


            })

        viewModelScope.launch {
            when(get("sss", Parameter(), ArticleItem::class.java)){
                is Result.Error ->{

                }
                is Result.Success ->{

                }
            }

        }
    }
}
